const path = require('path')
const myTheme = path.join(__dirname, "./src/assets/theme.less");
const pxtorem = require('postcss-pxtorem');
const Timestamp = new Date().getTime();
module.exports = {
    lintOnSave: false,
    productionSourceMap: false,
    outputDir: process.env.outputDir,
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [
                path.resolve(__dirname, './src/assets/common/global.less')
            ]
        },
    },
    configureWebpack: {
        output: {
            filename: `js/[name].${Timestamp}.js`, // 每次构建打包时给文件名加上时间戳，确保每次版本更新的文件名不一样
            chunkFilename: `js/[name].${Timestamp}.js`
        }
    },

    // configureWebpack: config=>{
    //     config.entry.app = ['babel-polyfill', './src/main.js']
    // },
    devServer: {
        proxy: {
            '/api': {
                target: 'http://yundun.diandianhuikj.com/admin-domain/api/',
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''
                }
            }
        }
    },
    css: {
        loaderOptions: {
            less: {
                modifyVars: {
                    // blue: '#FF5352',
                    hack: `true; @import "${myTheme}";`,
                }
            },
            postcss: {
                plugins: [
                    pxtorem({
                        rootValue: 37.5,
                        propList: ['*']
                    })
                ]
            }
        }
    }
}
